@extends('layouts.admin.application')
@section('content')

    <div class="admin-content">
        <div class="admin-content-body">
            <div class="am-cf am-padding am-padding-bottom-0">
                <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">教练管理</strong> /
                    <small>List</small>
                </div>
            </div>
            @include('admin._flash')
            <hr>

            <div class="am-g">
                <div class="am-u-sm-12 am-u-md-6">
                    <div class="am-btn-toolbar">
                        <div class="am-btn-group am-btn-group-xs">
                            <a href="/admin/fixfxs/create" type="button" class="am-btn am-btn-default"><span
                                        class="am-icon-plus"></span> 新增</a>
                            <button type="button" class="am-btn am-btn-default delete_all"><span
                                        class="am-icon-trash-o"></span> 删除
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="am-g"  >
                <div class="am-u-sm-12 am-u-md-12">
                    <form class="am-form-inline" method="get">
                        <div class="am-form-group">
                            <div class="am-input-group am-input-group-sm">
                                <input type="text" class="am-form-field" name="name"
                                       value="{{Request::input('name')}}" placeholder="按名字搜索">
                            </div>
                        </div>
                        <div class="am-form-group">
                            <select data-am-selected="{btnSize: 'sm', maxHeight: 360, searchBox: 1}"
                                    name="store_id">
                                <option value="-1">所有门店</option>
                                @foreach($cates as $c)
                                    <option value="{{$c->id}}"
                                            @if(Request::input('store_id')==$c->id) selected @endif>{{$c->name}}</option>
                                @endforeach
                            </select>
                        </div>
                        <div class="am-form-group" style="margin-top: 3px">
                            <button type="submit" class="am-btn am-btn-default am-btn-sm">查询</button>
                            <a href="/admin/fixfxs" class="am-btn am-btn-default am-btn-sm">重置</a>
                        </div>
                    </form>
                </div>

            </div>
            <hr>


            <div class="am-g">
                <div class="am-u-sm-12">
                    <form class="am-form">
                        <table class="am-table am-table-striped am-table-hover table-main">
                            <thead>
                            <tr style="font-size: 1.6rem">
                                <th><input class="check_all" type="checkbox"></th>
                                <th class="table-id">ID</th>
                                <th class="table-type">姓名</th>
                                <th class="table-type">编号</th>
                                <th class="table-type">头像</th>
                                <th class="table-type">签名</th>
                                <th class="table-type">电话</th>

                                <th class="table-type">标签</th>
                                <th class="table-type">参与预约</th>
                                {{--<th class="table-type">交易单数</th>--}}
                                {{--<th class="table-type">交易额</th>--}}
                                {{--<th class="table-type">交易提成</th>--}}

                                <th class="table-type">所属门店</th>
                                <th class="table-set">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($fixfxs as  $k=> $fxs)
                                <tr data-id="{{$fxs->id}}" style="font-size: 1.6rem">
                                    <th><input class="checked_id" name="checked_id[]" value="" type="checkbox"></th>
                                    <td>{{$k+1}}</td>
                                    <td>{{$fxs->name}}</td>
                                    <td>
                                        <label class="am-btn am-btn-secondary am-btn-xs am-radius" >
                                            {{$fxs->number}}
                                        </label>

                                    </td>
                                    <td><img src="{{$fxs->image}}" alt="" height="80" width="80"></td>
                                    <td>{{$fxs->sign}}</td>
                                    <td>{{$fxs->tel}}</td>

                                    <td>@foreach($fxs->tags as $t)
                                            <span class="am-btn am-btn-danger am-btn-xs am-radius">
                                             {{$t->name}}
                                        </span>
                                        @endforeach
                                    </td>
                                    <td>
                                        @if($fxs->is_use == 1)
                                            <span class="am-icon-check change_attr" data-id="1" style="color:deepskyblue;"></span>
                                        @endif
                                        @if($fxs->is_use == 0)
                                            <span class="am-icon-close danger change_attr" data-id="0"  style="color:red;"></span>
                                        @endif
                                    </td>
                                    <td>
                                        <label class="am-btn am-btn-secondary am-btn-xs am-radius" >
                                            {{$fxs['store']['name']}}
                                        </label>


                                    </td>



                                    <td>
                                        <div class="am-btn-toolbar">
                                            <div class="am-btn-group am-btn-group-xs">
                                                <a href="/admin/fixfxs/{{$fxs->id}}/edit" class="am-btn am-btn-primary am-btn-xs"><span
                                                            class="am-icon-pencil-square-o"></span> 编辑
                                                </a>
                                                <a href="/admin/del/{{$fxs->id}}"
                                                   data-method="delete"
                                                   data-token="{{csrf_token()}}" data-confirm="确认删除吗?"
                                                   class="am-btn am-btn-danger am-btn-xs del_one">
                                                    <span class="am-icon-trash-o"></span> 删除
                                                </a>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                            @endforeach


                            </tbody>
                        </table>
                        共 {{$fixfxs->count()}} 条记录

                        <div class="am-cf">
                            <div class="am-fr">
                                {!! $fixfxs->appends(Request::all())->links() !!}
                            </div>
                        </div>
                        <hr/>
                        <p>注：.....</p>
                    </form>
                </div>

            </div>
        </div>

        <footer class="admin-content-footer">
            <hr>
            <p class="am-padding-left">© 2014 AllMobilize, Inc. Licensed under MIT license.</p>
        </footer>

    </div>


@endsection

@section('js')


    <script>
        $(function () {

            //改变属性
            $('.change_attr').click(function () {
                // alert(111);

                var id = $(this).parents('tr').data('id');
                var attr = $(this).data('id')

                var _this = $(this);


                $.ajax({
                    type: 'PATCH',
                    url: '/admin/change_attr',
                    data: {id: id, attr: attr},
                    success: function () {
                        _this.toggleClass('am-icon-check am-icon-close');
                    }
                })

            })







            //全选按钮
            $('.check_all').click(function () {
                var checked = $(this).prop('checked');
                $('.checked_id').prop('checked', checked);
            })



        })
    </script>
@endsection